#include <cstdio>
#include <cmath>
#include "vector.h"

MyVector3d MyVector3d::crossproduct(const MyVector3d & v2) {
	//printf("cross product %d %d\n", x * v2.y, y * v2.x);
	return MyVector3d(y * v2.w - w * v2.y, w * v2.x - x * v2.w, x * v2.y - y * v2.x);
}

void MyVector3d::operator=(const MyVector3d & v2) {
	x = v2.x;
	y = v2.y;
	w = v2.w;
}

void MyVector3d::normalize() {
	if (w != 0.0) {
		x /= w;
		y /= w;
		w = 1.0;
		printf("normal: %lf %lf %lf\n",x,y,w);
	}
}

double D2(const MyVector3d& v1, const MyVector3d& v2) {
	return sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.w - v2.w) * (v1.w - v2.w));
}